<? include 'server_config.php'; 

if($_SESSION['user_idx'] == "")
{
	?>
	<script>
		location.href='login.php';
	</script>
	<?
	return;
}

$comment_idx = $_GET['idx'];
?>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<?

$sql = "
SELECT user_idx, document_idx 
FROM ndd_comment
WHERE 
comment_idx = '$comment_idx' ;
";

//echo $sql;
$result = mysql_query($sql,$connect);
$row = mysql_fetch_row($result);

if($_SESSION['user_idx'] != $row[0] || $row[1]=="")
{
	return;
}

$document_idx = $row[1];

$sql = "
DELETE FROM ndd_comment
WHERE 
comment_idx = '$comment_idx' AND user_idx = '".$_SESSION['user_idx']."' ;
";

//echo $sql;
$result = mysql_query($sql,$connect);

$sql = "
DELETE FROM ndd_comment
WHERE 
upper_idx = '$comment_idx';
";

//echo $sql;
$result = mysql_query($sql,$connect);



$sql = "
UPDATE ndd_document SET comment_count = comment_count-1 WHERE document_idx = '$document_idx' AND comment_count>0;
";

//echo $sql;
$result = mysql_query($sql,$connect);



?>
<script type="text/javascript" src="./js/jquery-1.6.2.min.js"></script>
<script> 
//parent.location.reload();
//location.replace("<? echo $_POST['current_location']; ?>");
parent.talk_display_article(<? echo $document_idx; ?>);
</script>











